home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / facilis2.arc / FACILIS.IM < prev    next >
Text File  |  1991-04-28  |  18KB  |  455 lines

  1.                     Facilis Implementation Manual
  2.  
  3. Version 0.30                                              File: FACILIS.IM
  4.                                                           Updated: 13 Jul 85
  5.  
  6.  
  7.  
  8. INTRODUCTION
  9.  
  10.    Facilis is implemented in Turbo Pascal, an excellent commercial compiler
  11. sold by Borland International.  You must have Turbo to compile the Facilis
  12. source files; it is not capable of compiling itself.
  13.    The source code is contained in three files:
  14.                FACILIS.PAS  -  main program
  15.                BLOCK.PAS    -  an include file
  16.                INTERPRT.PAS -  an include file
  17.    The implementation exploits certain non-standard features of Turbo, such
  18. as the MEM array, and utilizes the segment:offset addressing of the 8088.
  19. Modifications may be required to compile under a different Pascal compiler
  20. or for a different processor.
  21.    This implementation was done on an IBM PC running the PC-DOS version of
  22. Turbo.  However, it makes no explicit calls to DOS, and should compile
  23. under the CP/M-86 version of Turbo with little or no change.
  24.  
  25.  
  26.  
  27. COMPILING THE COMPILER
  28.  
  29.    The source files may be placed on any drive(s).  A RAM drive is recommended
  30. to save wear on your disks.  Turbo expects to find BLOCK.PAS and INTERPRT.PAS
  31. on the logged drive.  To override this assumption, you can place explicit drive
  32. specifiers in the {$I include directives within FACILIS.PAS.
  33.    Run Turbo.  From the main menu, enter FACILIS.PAS as the Main file.
  34. Go to the Options menu and choose the Com option.  (Because it uses overlays,
  35. Facilis cannot be compiled in memory.)  Quit to the main menu and Compile.
  36.    Compilation results in two files: FACILIS.COM and an overlay file,
  37. FACILIS.000.  These files will be written to the drive that FACILIS.PAS is
  38. loaded from, not necessarily the logged drive.  These are big files.  Allow
  39. enough space or you will get an error writing to disk, aborting compilation.
  40.  
  41.  
  42.  
  43.  
  44. SYNTAX DIAGRAMS
  45.  
  46. (All words in caps are required key words)
  47.  
  48.  
  49. program
  50.                               +----------->----------------------+
  51.                               |                                  |
  52. ---> PROGRAM ---> identifier -+-> ( ---> identifier list ---> ) -+-> ; ---+
  53.                                                                           |
  54.           +-------------------------------------------------------------<-+
  55.           |
  56.           +--> block ------> .
  57.  
  58.  
  59. block
  60.  
  61. --+---> CONST ---+---> identifier --------> = ---> constant ---> ; ---+
  62.   |              ^                                                    |
  63.   +-<------------+--------------------------------------------------<-+
  64.   |
  65.   +---> TYPE ----+---> identifier --------> = ---> type -------> ; ---+
  66.   |              ^                                                    |
  67.   +-<------------+--------------------------------------------------<-+
  68.   |
  69.   +---> VAR ---------> identifier list ---> : ---> type -------> ; ---+
  70.   |                                                                   |
  71.   +-<---------------------------------------------------------------<-+
  72.   |
  73.   v
  74.   |
  75.   +-+-> PROCEDURE ---> identifier --------> formal parameter list  ---+
  76.   | ^                                                                 |
  77.   v |                                                                 |
  78.   +-+-<----------- ; <------- block <---------- ; <-------------------+
  79.   |                                                                   |
  80.   +---> FUNCTION ----> identifier ----> formal parameter list ---+    ^
  81.   |                                                              |    |
  82.   |       +-<----------------------------------------------------+    |
  83.   |       |                                                           |
  84.   |       +---> : ----------> type identifier ---------------------->-+
  85.   |
  86.   +---> BEGIN -------> statement sequence -----> END ----->
  87.  
  88.  
  89. type
  90.  
  91. --+-----------------------> type identifier --------------------------------+->
  92.   |                                                                         |
  93.   +--> ARRAY --> [ -+> constant --> .. --> constant -+> ] --> OF --> type --+
  94.   |                 |                                |                      |
  95.   |                 +--------------  , <-------------+                      |
  96.   |                                                                         |
  97.   |              +->-------------------------------------->-+               |
  98.   |              |                                          |               |
  99.   +--> RECORD ---+-+-> identifier list ---> : ---> type -+--+-> END ------>-+
  100.                    |                                     |
  101.                    +----------------------- ; <----------+
  102.  
  103.  
  104. formal parameter list
  105.  
  106.   +->--------------------------------------------------------------------->-+
  107.   |                                                                         |
  108. --+-> ( -+-+->-------+--> identifier list --> : --> type identifier -+-> ) -+->
  109.          | |         |                                               |
  110.          | +-> VAR --+                                               |
  111.          |                                                           |
  112.          +-<--------------------------------- ; <--------------------+
  113.  
  114.  
  115. identifier list
  116.  
  117. -----------------+--->  identifier  ----+---------------------------->------->
  118.                  |                      |
  119.                  +--------- , <---------+
  120.  
  121.  
  122. identifier
  123.  
  124. -----------------> letter -----+--->-----------+--------------------->------->
  125.                                ^               |
  126.                                +--- letter <---+
  127.                                |               |
  128.                                +--- digit  <---+
  129.                                |               |
  130.                                +----  _  <-----+
  131.  
  132.  
  133. statement sequence
  134.  
  135. -----------------+--->  statement   ----+---------------------------->------->
  136.                  ^                      |
  137.                  +--------- ; <---------+
  138.  
  139.  
  140. statement
  141.  
  142. --+--+-> variable -------------+--> := ---------> expression ------------->-+->
  143.   |  |                         |                                            |
  144.   |  +-> function identifier --+                                            |
  145.   |                                                                         |
  146.   +----> procedure identifier ----+---> actual parameter list ---+-------->-+
  147.   |                               |                              |          |
  148.   |                               +--->--------------------------+          |
  149.   |                                                                         |
  150.   +----> BEGIN ------> statement sequence ------> END -------------------->-+
  151.   |                                                                         |
  152.   |                                              +->---------------------->-|
  153.   |                                              |                          |
  154.   +--> IF --> expression --> THEN --> statement -+-> ELSE --> statement -->-+
  155.   |                                                                         |
  156.   |                            +--->-------------------------------+        |
  157.   |                            |                                   |        |
  158.   +-> CASE -> expression -> OF +-+-> constant +-> : -> statement +-+-> END -+
  159.   |                              |            |                  |          |
  160.   |                              +----- , <---+                  |          |
  161.   |                              |                               |          |
  162.   |                              +--------------- ; <------------+          |
  163.   |                                                                         |
  164.   +----> WHILE ----> expression ------> DO ------> statement ------------->-+
  165.   |                                                                         |
  166.   +----> REPEAT ---> statement sequence ---> UNTIL ---> expression ------->-+
  167.   |                                                                         |
  168.   +----> FOR ------> variable identifier ---> := ---> expression --+        |
  169.   |                                                                |        |
  170.   |    +----<----------------------------------------------------<-+        |
  171.   |    |                                                                    |
  172.   |    +--+-> TO -------+--> expression ---> DO ---> statement ----------->-+
  173.   |       |             |                                                   |
  174.   |       +-> DOWNTO ---+                                                   |
  175.   |                                                                         |
  176.   +---->------------------------------------------------------------------>-+
  177.  
  178.  
  179. expression
  180.  
  181. ---> simple expression --+---+---+---+---+---+------------------------->-+-->
  182.                          |   |   |   |   |   |                           |
  183.                          v   v   v   v   v   v                           |
  184.                          =   <>  <   >   >=  <=                          |
  185.                          |   |   |   |   |   |                           |
  186.                          +---+---+---+---+---+--> simple expression --->-+
  187.  
  188.  
  189. simple expression
  190.  
  191. ---+-->-----+--> term ----+--->-----------------+----+----+---------->------>
  192.    |        |             |                     |    |    |
  193.    +--> + --+             |                     v    v    v
  194.    |        |             |                     +    -    OR
  195.    +--> - --+             |                     |    |    |
  196.                           +---- term <----------+----+----+
  197.  
  198.  
  199. term
  200.  
  201. ------> factor -----------+--->------------+----+----+----+----+----->------>
  202.                           |                |    |    |    |    |
  203.                           |                v    v    v    v    v
  204.                           |                *    /   DIV  MOD  AND
  205.                           |                |    |    |    |    |
  206.                           +--- factor <----+----+----+----+----+
  207.  
  208.  
  209. factor
  210.  
  211. ---+--> unsigned constant --------------------------------------------->-+-->
  212.    |                                                                     |
  213.    +--> variable ------------------------------------------------------>-+
  214.    |                                                                     |
  215.    +--> function identifier ------> actual parameter list ------------->-+
  216.    |                                                                     |
  217.    +--> ( -------> expression ----> ) --------------------------------->-+
  218.    |                                                                     |
  219.    +--> NOT -----> factor --------------------------------------------->-+
  220.  
  221.  
  222. actual parameter list
  223.  
  224. ------> ( ------+---> expression ---+------> ) ---------------------->------>
  225.                 |                   |
  226.                 +-------- , <-------+
  227.  
  228.  
  229. variable
  230.  
  231. ----> variable identifier ---+----+--->------------------------------>------->
  232.                              |    |
  233.                              |    +---> [ --+--> expression --+--> ] --+
  234.                              ^    |         |                 |        |
  235.                              |    |         +------- , <------+        |
  236.                              |    |                                    |
  237.                              |    +---> . -----> field identifier -->--+
  238.                              |                                         |
  239.                              +---<----------------------------------<--+
  240.  
  241.  
  242. constant
  243.  
  244. ---+---+-->-----+-----+---> unsigned number ---------------->-+------>------>
  245.    |   |        |     |                                       |
  246.    |   +--> + --+     |                                       |
  247.    |   |        |     +---> constant identifier ------------>-+
  248.    |   +--> - --+                                             |
  249.    |                                                          |
  250.    +----------------------> literal string ----------------->-+
  251.  
  252.  
  253. unsigned constant
  254.  
  255. ---+------> constant identifier ---------------------------->-+------>------>
  256.    |                                                          |
  257.    +------> unsigned number -------------------------------->-+
  258.    |                                                          |
  259.    +------> literal string --------------------------------->-+
  260.  
  261.  
  262. literal string
  263.  
  264. -------> ' -----+----------->----------+-----> ' ------------>-------------->
  265.                 |                      |
  266.                 +-----> character -----+
  267.                 |                      |
  268.                 +-----------<----------+
  269.  
  270.  
  271. unsigned number
  272.  
  273. ---> unsigned integer ---+--->----------------------------------+->-+------->
  274.                          |                                      |   |
  275.                          +---> . ----> unsigned integer --+--->-+   |
  276.                          |                                |         |
  277.                          v                                |         |
  278.                          +---<-------------------------<--+         |
  279.                          |                                          |
  280.                          +---> E --+-->-----+-> unsigned integer ->-+
  281.                                    |        |
  282.                                    +--> + --+
  283.                                    |        |
  284.                                    +--> - --+
  285.  
  286. unsigned number
  287.  
  288. ------------------------+-----> digit -----+------------------------->------>
  289.                         |                  |
  290.                         +-----<------------+
  291.  
  292.  
  293.  
  294. RESERVED WORDS
  295.  
  296. The following symbols are reserved and cannot be used as identifiers:
  297.  
  298.     AND         DOWNTO      IF          OR          THEN
  299.     ARRAY       ELSE        IN          PACKED      TO
  300.     BEGIN       END         LABEL       PROCEDURE   TYPE
  301.     CASE        FILE        MOD         PROGRAM     UNTIL
  302.     CONST       FOR         NIL         RECORD      VAR
  303.     DIV         FUNCTION    NOT         REPEAT      WHILE
  304.     DO          GOTO        OF          SET         WITH
  305.  
  306.  
  307.  
  308. OPERATION CODES
  309.  
  310. These are shown in the list file when the T option is selected.
  311. Operations take zero, one, or two operands: x represents an 8-bit operand,
  312. usually a level number; y represents a 16-bit quantity, such as an address
  313. or an integer.
  314.  
  315. Code          Action
  316.   0  x  y  Load address
  317.   1  x  y  Load value
  318.   2  x  y  Load indirect
  319.   3  x  y  Update DISPLAY
  320.   4          not used
  321.   5          not used
  322.   6          not used
  323.   7     y  Concatenate
  324.   8     y  Built-in functions
  325.   9     y  Add y to the element on top of the stack
  326.  10     y  Jump to y (unconditional)
  327.  11     y  Jump to y if stack top false
  328.  12     y  Jump to y (case table) and select entry
  329.  13     y  Entry in case table ... NOT EXECUTABLE
  330.  14     y  For loop entry test - UP
  331.  15     y  For loop retry test - UP
  332.  16     y  For loop entry test - DOWN
  333.  17     y  For loop retry test - DOWN
  334.  18     y  Mark stack
  335.  19     y  Call user procedure
  336.  20     y  Indexed fetch (element size > 1)
  337.  21     y  Indexed fetch
  338.  22     y  Load block
  339.  23     y  Copy block
  340.  24     y  Load literal
  341.  25     y  Load real
  342.  26     y  Float
  343.  27     y  Read (y denotes type .. 1 integer, 2 real, 4 char)
  344.  28     y  Write string
  345.  29     y  Write - default field widths
  346.  30     y  Write - defined field widths
  347.  31     y  Assign string (of length 1) to char
  348.  32     y  Relation operators for strings
  349.  
  350.  33-130      not used
  351.  
  352. 131        Halt
  353. 132        Exit procedure
  354. 133        Exit function
  355. 134        Fetch
  356. 135        Not
  357. 136        - integer (unary)
  358. 137        Write real - defined field
  359. 138        Store
  360. 139        Real =
  361. 140        Real <>
  362. 141        Real <
  363. 142        Real <=
  364. 143        Real >
  365. 144        Real >=
  366. 145        Integer =
  367. 146        Integer <>
  368. 147        Integer <
  369. 148        Integer <=
  370. 149        Integer >
  371. 150        Integer >=
  372. 151        Or
  373. 152        + integer
  374. 153        - integer
  375. 154        + real
  376. 155        - real
  377. 156        And
  378. 157        * integer
  379. 158        Div
  380. 159        Mod
  381. 160        * real
  382. 161        /
  383. 162        Readln
  384. 163        Writeln
  385. 164        - real (unary)
  386. 165        Index string
  387. 166        Assign string temporary to string
  388. 167        Convert array to string
  389. 168        Assign character to string
  390. 169        Assign string to string
  391. 170        Write string
  392. 171        Write string temporary
  393. 172        Value parameter - string
  394. 173        Value parameter - string temporary
  395. 174        Convert string to array
  396. 175        Convert string temporary to array
  397. 176        Write string - defined field
  398. 177        Write string temporary - defined field
  399.  
  400. 178-255     not used
  401.  
  402.  
  403. BUILT-IN FUNCTIONS
  404.  
  405. Most of the built-in functions and procedures generate opcode 8 with a
  406. y operand that encodes the particular function.
  407.  
  408. code      function
  409.   0     Abs - real
  410.   1     Abs - integer
  411.   2     Sqr - real
  412.   3     Sqr - integer
  413.   4     Odd
  414.   5     Chr
  415.   6     Ord
  416.   7     Succ
  417.   8     Pred
  418.   9     Round
  419.  10     Trunc
  420.  11     Sin
  421.  12     Cos
  422.  13     Exp
  423.  14     Ln
  424.  15     Sqrt
  425.  16     Arctan
  426.  17     Eof
  427.  18     Eoln
  428.  19     Maxavail
  429.  20-22  Length
  430.  23-25  Copy
  431.  26-32  Pos
  432.  33-34  Str
  433.  35-36  Val
  434.  37-38  Rval
  435.  39     Keypressed
  436.  40     Random - integer
  437.  41     Random - real
  438.  42     Upcase
  439.  43     Randomize
  440.  44     Clrscr
  441.  45     Gotoxy
  442.  46     Textcolor
  443.  47     Inkey
  444.  48     Wherex
  445.  49     Wherey
  446.  50     Delay
  447.  51     Textbackground
  448.  52     Sound
  449.  53     Nosound
  450. xtcolor
  451.  47     Inkey
  452.  48     Wherex
  453.  49     Wherey
  454.  50     Delay
  455.  51